using System;
using System.Collections.Generic;
using System.Collections ;
using System.Text;
using BuildingBasicDomain;
using MVCFramework;



namespace BuildingStructuralElements
{
    [Serializable ]
    public class Node : Point,  ISelectable, ICountable,IModelData , IModifiable
    {
        # region " private Decleration  "

        public event EventHandler<EventArgs> OnMove;

        private IDictionary<StructuralElement, Constrain> _constraints 
            =new Dictionary<StructuralElement, Constrain>();

   
        public Constrain this[StructuralElement element]
        {
            get 
            {
                System.Diagnostics.Debug.Assert(element != null, " beam Is Null");

                if (_constraints.ContainsKey(element))
                    return _constraints[element];
                else
                {
                    Constrain constraint = new Constrain();
                    _constraints.Add(element, constraint);
                    return constraint;
                }
            }
            set 
            {
                if (_constraints.ContainsKey(element))
                    _constraints[element] = value;
                else
                {
                    Constrain constraint = value;
                    _constraints.Add(element, constraint);
                }
            }
        }

        public bool IsSupported()
        {
            return false;
        }

        # endregion

        public Node(double x, double y, double z) : base(x, y, z) { }    

        # region " ISelectable implementation "

        private bool isSelected;
        public bool IsSelected
        {
            get { return isSelected; }
            set { this.isSelected = value; }
        }
        # endregion

        # region "Casting implementation"
/*
        public static explicit operator Node(GridPoint gPoint)
        {
            return new Node(gPoint.X, gPoint.Y, gPoint.Z);
        }

        public static explicit  operator Node(double[] X)
        {
            return new Node(X[0], X[1], X[2]);
        }
        */
        #endregion

        public static Node CreateNode(IPoint point)
        {
            if (point != null) 
            return new Node(point.X, point.Y, point.Z);
        else return null;
        }

        #region IModifiable Members

        bool IModifiable.Move(CommonTypes.Vector v)
        {
            return base.Move(v);
        }


        #endregion
    }
}
